package com.example.ui.fragment;

import android.os.SystemClock;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.administrator.sharker_demo.R;
import com.example.ui.activity.BaseActivity;
import com.example.ui.activity.MainActivity;
import com.example.ui.adapter.AD_VP_Adapter;
import java.util.ArrayList;

import butterknife.BindView;

/**
 * 董建业  时间:2017/4/12.
 * <p>
 * 课程列表
 */

public class AllDataFragment extends TransitionFragment{

    @BindView(R.id.head_topreturn_img)
    ImageView headTopreturnImg;
    @BindView(R.id.head_title_tv)
    TextView headTitleTv;
    @BindView(R.id.alldata_course_tv)
    TextView alldataCourseTv;
    @BindView(R.id.alldata_course_img)
    ImageView alldataCourseImg;
    @BindView(R.id.alldata_tablayout)
    TabLayout alldataTablayout;
    @BindView(R.id.alldata_viewpager)
    ViewPager alldataViewpager;
    private ArrayList<Fragment> listfragment;

    @Override
    public int getlayoutid() {
        return R.layout.fragment_alldata;
    }

    @Override
    protected void initview(View view) {
        MainActivity activity = (MainActivity) getActivity();
        int type = activity.getAlldatatype();
        if (type == 1)
            headTitleTv.setText("免费试听");
        if (type==5)
            headTitleTv.setText("精选课程");
        if(type==9)
            headTitleTv.setText("专辑课程");
        alldataTablayout.setTabMode(TabLayout.MODE_FIXED);
    }

    @Override
    protected void viewbehavior() {
        listfragment = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            listfragment.add(new AllDataItemFragment());
        }
        alldataViewpager.setAdapter(new AD_VP_Adapter(getFragmentManager(),listfragment));
        alldataViewpager.setCurrentItem(0);
        alldataTablayout.setupWithViewPager(alldataViewpager);

        headTopreturnImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseActivity activity = (BaseActivity) getActivity();
                activity.isreturn();
            }
        });
    }

}
